package com.p2p.auth.service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Antinomy on 16/10/26.
 */
public class DateFormatService {

    public static String toDay(Date date) {
        if(date ==null) return "";

        return  new SimpleDateFormat("yyyy-MM-dd").format(date);
    }

    public static String toMonth(Date date) {
        if(date ==null) return "";

        return  new SimpleDateFormat("yyyy-MM").format(date);
    }

    public static String toTime(Date date) {
        if(date ==null) return "";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return  sdf.format(date);
    }
}
